<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/include/head.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript"
	src="<%=WEBPATH%>/dwr/interface/CustomerAction.js?id=<%=generate%>"></script>
<title><html:text name="sys.name" /></title>
</head>
<body>

<form id="listDataForm" method="post"
	action="<%=WEBPATH%>/client/index.crm">
<table class="condition-table">
	<tr>
		<td colspan="4" class="x-panel-header" align="center"><html:text
			name="client" /><html:text name="entity.list" /></td>
	</tr>
	<tr>
		<td><html:text name="client.clientName"></html:text><html:hidden
			id="asc" name="asc" /></td>
		<td><html:textfield id="customerBean.clientName"
			name="customerBean.clientName"></html:textfield></td>
		<td><html:text name="client.clientCode"></html:text><html:hidden
			id="orderBy" name="orderBy" /></td>
		<td><html:textfield id="customerBean.clientCode"
			name="customerBean.clientCode"></html:textfield></td>
	</tr>
	<tr>
		<td><html:text name="client.mainTelephone"></html:text></td>
		<td><html:textfield id="customerBean.mainTelephone"
			name="customerBean.mainTelephone"></html:textfield></td>
		<td><html:text name="client.clientType"></html:text></td>
		<td><html:textfield id="customerBean.clientType"
			name="customerBean.clientType"></html:textfield></td>
	</tr>
	<tr>
		<td><html:text name="client.clientLevel"></html:text></td>
		<td><html:select id="customerBean.clientLevel"
			name="customerBean.clientLevel" list="customerLevels"
			listValue="name" listKey="id"></html:select></td>
		<td><html:text name="client.clientSource"></html:text></td>
		<td><html:select id="customerBean.clientSource"
			name="customerBean.clientSource" list="customerSources"
			listValue="name" listKey="id"></html:select></td>
	</tr>
	<tr>
		<td><html:text name="client.clientKind"></html:text></td>
		<td><html:select id="customerBean.clientKind"
			name="customerBean.clientKind" list="customerKinds" listValue="name"
			listKey="id">
		</html:select></td>
		<td><html:text name="client.clientTrade"></html:text></td>
		<td><html:select id="customerBean.clientTrade"
			name="customerBean.clientTrade" list="customerTrades"
			listValue="name" listKey="id"></html:select></td>
	</tr>
	<tr>
		<td align="right">&nbsp;</td>
		<td colspan="3"><input type="submit" class="querybutton"
			value="<html:text name="button.query"/>">&nbsp;&nbsp; <input
			type="button" id="new" name="new" onclick="javascript:newFunction();"
			value="<html:text name="button.new"/>">&nbsp;&nbsp; <input
			type="button" id="delete" name="delete"
			onclick="javascript:deleteFunction();"
			value="<html:text name="button.delete"/>">&nbsp;&nbsp; <input
			type="button" id="edit" name="edit"
			onclick="javascript:editFunction();"
			value="<html:text name="button.modify"/>">&nbsp;&nbsp; <input
			type="button" id="view" name="view"
			onclick="javascript:viewFunction();"
			value="<html:text name="button.view"/>"></td>
	</tr>
</table>
<script type="text/javascript">
	function newFunction(){
		window.location="<%=WEBPATH%>/client/create.crm";
	}
	function deleteFunction(){
		if(checkSelectData()){
			var id=checkMultiSelectData();
			if(id==null||id=="0"){
				alert("<html:text name="entity.deleted.select"/>");
				return ;
			}
			if(confirm("<html:text name="entity.deleted.confirm"/>")){
				//alert(id);
				CustomerAction.dwrDelete(id,callFunction);
			}
		}else{
			alert("<html:text name="entity.deleted.select"/>");
		}
		
	}
	function callFunction(data){
		if(data=="success"){
			alert("<html:text name="entity.deleted"/>");
			_$("listDataForm").submit();
		}else{ 
			alert("<html:text name="entity.deleted.error"/>");
		}
	}
	function editFunction(){
		if(checkSelectData()){
			var id=checkBooleanSelectData();
			if(id==null){
				alert("<html:text name="entity.updated.select"/>");
				return ;
			}
			window.location="<%=WEBPATH%>/client/edit.crm?id="+id;
		}else{
			alert("<html:text name="entity.updated.select"/>");
		}
	}
	function viewFunction(){
		if(checkSelectData()){
			var id=checkBooleanSelectData();
			if(id==null){
				alert("<html:text name="entity.view.select"/>");
				return ;
			}
			window.location="<%=WEBPATH%>/client/view.crm?id="+id;
		}else{
			alert("<html:text name="entity.view.select"/>");
		} 
	}
	function imgOnclick(orderBy,asc){
		jQuery("#orderBy").val(orderBy);
		jQuery("#asc").val(asc);
		_$("listDataForm").submit();
	}
</script>
<table class="datatable">
	<tr class="thead">
		<td align="left" width="80"><input type="checkbox" id="checkList"
			onclick="javascript:onSelectChange(this);"><html:text
			name="entity.choose" /></td>
		<td width="200" align="left"
			<html:if test="asc"> onclick="javascript:imgOnclick('clientName',false);"</html:if>
			<html:else> onclick="javascript:imgOnclick('clientName',true);"</html:else>><html:text
			name="client.clientName" /><html:if test="orderBy=='clientName'">&nbsp;<img
				class="sort-arrow"
				<html:if test="asc"> src="<%=WEBPATH%>/images/arrow_up.png"</html:if>
				<html:else> src="<%=WEBPATH%>/images/arrow_down.png"</html:else> />
		</html:if></td>
		<td width="100" align="left"
			<html:if test="asc"> onclick="javascript:imgOnclick('clientType',false);"</html:if>
			<html:else> onclick="javascript:imgOnclick('clientType',true);"</html:else>><html:text
			name="client.clientType" /><html:if test="orderBy=='clientType'">&nbsp;<img
				class="sort-arrow"
				<html:if test="asc"> src="<%=WEBPATH%>/images/arrow_up.png"</html:if>
				<html:else> src="<%=WEBPATH%>/images/arrow_down.png"</html:else> />
		</html:if></td>
		<td width="100" align="left"
			<html:if test="asc"> onclick="javascript:imgOnclick('clientLevel',false);"</html:if>
			<html:else> onclick="javascript:imgOnclick('clientLevel',true);"</html:else>><html:text
			name="client.clientLevel" /><html:if test="orderBy=='clientLevel'">&nbsp;<img
				class="sort-arrow"
				<html:if test="asc"> src="<%=WEBPATH%>/images/arrow_up.png"</html:if>
				<html:else> src="<%=WEBPATH%>/images/arrow_down.png"</html:else> />
		</html:if></td>
		<td width="100" align="left"
			<html:if test="asc"> onclick="javascript:imgOnclick('mainTelephone',false);"</html:if>
			<html:else> onclick="javascript:imgOnclick('mainTelephone',true);"</html:else>><html:text
			name="client.mainTelephone" /><html:if
			test="orderBy=='mainTelephone'">&nbsp;<img
				class="sort-arrow"
				<html:if test="asc"> src="<%=WEBPATH%>/images/arrow_up.png"</html:if>
				<html:else> src="<%=WEBPATH%>/images/arrow_down.png"</html:else> />
		</html:if></td>
		<td width="150" align="left"
			<html:if test="asc"> onclick="javascript:imgOnclick('email',false);"</html:if>
			<html:else> onclick="javascript:imgOnclick('email',true);"</html:else>><html:text
			name="client.email" /><html:if test="orderBy=='email'">&nbsp;<img
				class="sort-arrow"
				<html:if test="asc"> src="<%=WEBPATH%>/images/arrow_up.png"</html:if>
				<html:else> src="<%=WEBPATH%>/images/arrow_down.png"</html:else> />
		</html:if></td>
	</tr>
	<html:if test="customerBeanPages.result==null">
		<tbody>
			<tr>
				<td colspan="6"><html:text name="global.page.emptyMsg" /></td>
			</tr>
		</tbody>
		<script type="text/javascript">
			jQuery("#delete").hide();
			jQuery("#edit").hide();
			jQuery("#view").hide(); 
		</script>
	</html:if>
	<html:else>
		<html:iterator id="users" value="customerBeanPages.result"
			status="index">
			<tbody>
				<tr <html:if test="#index.odd">class="row_odd"</html:if>
					<html:else>class="row_even"</html:else>>
					<td align="left"><input type="checkbox" id="selectCheck"
						name="selectCheck" value="<html:property value="id"/>"></input></td>
					<td align="left"><html:property value="clientName" /></td>
					<td align="left"><html:property value="clientType" /></td>
					<td align="left"><html:property value="clientLevel" /></td>
					<td align="left"><html:property value="mainTelephone" /></td>
					<td align="left"><html:property value="email" /></td>
				</tr>
			</tbody>
		</html:iterator>
		<tr class="tfoot">
			<td colspan="6" align="right" valign="top"><script
				type="text/javascript">
				messages=new Array();
				messages[0]="<html:text name="global.page.first" />";
				messages[1]="<html:text name="global.page.prev" />";
				messages[2]="<html:text name="global.page.next" />";
				messages[3]="<html:text name="global.page.last" />";
				messages[4]="<html:text name="global.page.page" />";
				messages[5]="<html:text name="global.page.everyPage" />";
				messages[6]="<html:text name="global.page.total" />";
				messages[7]="<html:text name="global.page.record" />";
				messages[8]="<html:text name="global.page.primo" />";
				writePage(messages,"<%=WEBPATH%>","<html:property value="customerBeanPages.pageNo"/>","<html:property value="customerBeanPages.totalPages"/>","<html:property value="customerBeanPages.pageSize"/>");
				
			</script></td>
		</tr>
	</html:else>
</table>
</form>
<script language="javascript" type="text/javascript">
		function modifyData(id){
			window.location="<%=WEBPATH%>/client/edit.crm?id="+id;
		}
		jQuery(document).ready(
		function(){
			jQuery(".row_odd").mouseover(function(){ jQuery(this).addClass("row_active");}).mouseout(function(){ jQuery(this).removeClass("row_active");});
			jQuery(".row_even").mouseover(function(){ jQuery(this).addClass("row_active");}).mouseout(function(){ jQuery(this).removeClass("row_active");});
		});
</script>
</body>
</html>

